<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>聊天记录</title>
    <meta name="context-path" th:content="@{/}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/bootstrap-responsive.min.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-style.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-media.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-full.css}"/>
    <link rel="stylesheet" th:href="@{/resources/jquery-easyui/themes/metro/easyui.css}" />
    <link rel="stylesheet" th:href="@{/resources/matrix/font-awesome/css/font-awesome.css}"/>
    <link rel="stylesheet" th:href="@{/resources/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/resources/css/website.css}"/>

</head>
<body class="childbody">
<div class="container-fluid">
    <div class="row-fluid">
        <div class="widget-box">
            <div class="widget-title bg_lg"><span class="icon"><i class="icon-search"></i></span>
                <h5>查询</h5>
            </div>
            <div class="widget-content nopadding">
                <form id="queryform1" action="#" method="get" class="form-horizontal query-form">
                    <input type="hidden"  name="userName" th:value="*{userName}">
                    <div class="row-fluid query-row">
                        <div class="span8">
                            <div class="control-group">
                                <label class="control-label query-control-label">时间</label>
                                <div class="controls query-controls">
                                    <input type="date" name="time"  id="time" class="span6" placeholder="查询前7天聊天记录">
                                    （查询前7天聊天记录）
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <button id="btnSearch" type="button" class="btn btn-primary">查询</button>
                    </div>
                </form>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"> <i class="icon-th"></i> </span>
                        <h5>聊天记录</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <table id="tablelist1" class="layui-table" lay-filter="record_list">
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/resources/js/jquery.min.js}"></script>
<script th:src="@{/resources/js/jquery-migrate-1.2.1.js}"></script>
<script th:src="@{/resources/jquery-easyui/jquery.easyui.min.js}"></script>
<script th:src="@{/resources/layui/layui.all.js}" charset="utf-8"></script>
<script th:src="@{/resources/valid/js/bootstrapValidator.js}"></script>
<script th:src="@{/resources/valid/js/language/zh_CN.js}"></script>
<script th:src="@{/resources/js/website.js}"></script>
<script th:src="@{/resources/js/system.js}"></script>
<script th:src="@{/resources/js/validation_fields.js}"></script>
<script th:src="@{/resources/uploader/AjaxFileUpload/ajaxfileupload.js}"></script>
<script th:src="@{/resources/js/upload.js}"></script>
<script th:inline="javascript">
    var contextRoot = $("meta[name='context-path']").attr("content");

    $(document).keyup(function (event) {
        if (event.keyCode == 13) {
            search();
        }
    });
</script>

<script th:inline="javascript">
    /*<![CDATA[*/

    var ListQueryRecord = function (table, params) {
        var self = this;
        self.cols = params.cols;
        self.element = params.element;
        self.url = params.url;
        self.page = params.page;
        self.tableid = params.tableid;
        self.pageable = true;
        self.even = true;
        self.filter = params.filter;
        self.extraData = params.extraData;
        self.onRowChecked = params.onRowChecked;
        self.onReload = params.onReload;
        if (params.pageable) {
            self.pageable = params.pageable;
        }
        if (params.even == false) {
            self.even = params.even;
        }

        table.render({
            elem: self.element,
            url: self.url,
            id: self.tableid,
            method: 'post',
            cols: self.cols,
            size: 'sm',
            even: self.even,
            page: self.pageable,
            where:self.extraData(),
            loading: true
        });

        /*if (self.filter) {
            table.on('tool(' + self.filter + ')', function (obj) {
                self.onRowChecked(obj);
            });
        }*/
        self.reload = function () {
            var whereData = self.extraData();
            console.log(whereData);
            table.reload(self.tableid, {
                page: {
                    curr: self.page
                }
                , where: whereData
            });

            if (self.onReload) {
                self.onReload();
            }
        };

    };

    var querys;
    layui.use(['jquery', 'layer', 'table', 'laydate'], function () {
        var $ = layui.jquery,
            layer1 = layui.layer,
            table1 = layui.table;

        lay('.date').each(function () {
            laydate.render({
                elem: this
            });
        });

        var cols = [
            [
                {type: 'checkbox'},
                {title:'消息发送人',width:'15%',field:'from_name'},
                {title:'消息发送时间',width:'15%',field:'msgTime'},
                {title:'消息接收人',width:'15%',field:'target_name'},
                {title:'内容',width:'50%',templet: function(d){
                        if(d.msgBody){
                            return d.msgBody.text
                        }
                        return "未知"
                    }
                }
            ]
        ];

        querys = new ListQueryRecord(table1, {
            cols: cols,
            element: "#tablelist1",
            url: contextRoot + "schoolStudentParent/doMessageList",
            page: 1,
            even:false,
            filter: "record_list",
            tableid: "parent_message_list_table",
            extraData: function () {
                return $("#queryform1").serializeObject();
            },
            onRowChecked: function (row) {

            },
            onReload: function () {

            }
        });

        $("#btnSearch").bind("click", function (event) {
            querys.reload();
        });

        querys.reload();

    });




    /*]]>*/
</script>
</body>
</html>